﻿CREATE PROCEDURE [ServiceEngine].[ListOperationVersionsByElement]
	@SchemaID uniqueidentifier,
	@ElementName nvarchar(400) 
AS
BEGIN
	SET NOCOUNT ON;

	SELECT	DISTINCT OV.OperationVersionID as ID
	FROM	[ServiceEngine].OperationVersions OV
	JOIN	[ServiceEngine].MessageParts MP on OV.OperationVersionID = MP.OperationVersionID
	JOIN	[ServiceEngine].SchemaObjects SO on SO.SchemaObjectID = MP.SchemaObjectID
	WHERE	SO.SchemaID = @SchemaID 
	AND		SO.SchemaObjectName = @ElementName
	AND		SO.DateRevised = NULL -- This is for the latest node
END


